<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/js/axios.min.js"></script>
    <script src="/js/util.js"></script>
    <SCRIPT>
        var postId;
        window.onload = function () {
            postId = getQuery("id");
            findById(postId);
        }

        function findById(postId) {
            axios.get("/mainPost/findById", {
                params: {
                    postId: postId
                }
            }).then(resp => {
                var str = "";
                var post = resp.data;
                console.log(post)
                $("titleSpan").innerHTML = post.title;
                $("nameSpan").innerHTML = post.author;
                $("faceImg").src = "/face/" + post.userBean.head;
                $("registerDate").innerHTML = post.userBean.date;
                $("titleSpan2").innerHTML = post.title;
                $("dateSpan").innerText = post.date;
                $("contentSpan").innerHTML = post.content;

                post.repliesBeanList.forEach(n => {
                    str += `<tr><td>${n.title}</td><td>${n.content}</td><td>${n.date}</td>
                <td>${n.author}</td></tr>`
                })
                $("repliesList").innerHTML = str;
            })
        }

        function add() {
            axios.get("/replies/add", {
                params: {
                    title: $("titleText").value,
                    content: $("contentText").value,
                    postId: postId
                }
            }).then(resp => {
                var info = resp.data;
                if (info == "ok") {
                    findById(postId);
                }
            })
        }
    </SCRIPT>
</head>
<body>
主题：<span id="titleSpan"></span><br>
楼主:<span id="nameSpan"> </span><br>
<img src="" id="faceImg"><br>
<span id="registerDate"></span><br>
主题：<span id="titleSpan2"></span><br>
<span id="dateSpan"></span><br>
<span id="contentSpan"></span><br>
<table border="1px" width="80%">
    <thead>
    <tr>
        <td>标题</td>
        <td>内容</td>
        <td>回帖人</td>
    </tr>
    </thead>
    <tbody id="repliesList">

    </tbody>
</table>

标题：<input type="text" id="titleText"><br>
内容：<input type="text" id="contentText"><br>
<input type="button" value="发表" onclick="add()"><br>
</body>
</html>